/*
 * CastDRAndroid
 * Copyright (c) 2014 Christian Holm Christensen
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.cholm.media.castdr;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.AttributeSet;
import android.view.View;
import static org.cholm.media.castdr.LogUtils.LOGd;


/**
 * A simple child class of the CastCompanion libraries MiniController that
 * checks to see if we should really hide this or not.
 */
public class MiniController extends com.google.sample.castcompanionlibrary
        .widgets.MiniController {
    private static final String TAG = LogUtils.makeLogTag(MiniController.class);

    public MiniController(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    /**
     * Set the enabled state of this view.
     *
     * @param visibility One of {@link #VISIBLE}, {@link #INVISIBLE}, or {@link #GONE}.
     * @attr ref android.R.styleable#View_visibility
     */
    @Override
    public void setVisibility(int visibility) {
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences
                (getContext());
        boolean alwaysVisible = sp.getBoolean("always_controller", false);
        int vis = (alwaysVisible ? View.VISIBLE : visibility);
        LOGd(TAG, "Setting visibility to " + vis + " request: " + visibility
                + " preference: " + alwaysVisible);
        super.setVisibility(vis);
    }
}
// EOF

